<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="fy.bean.*,java.util.*,java.io.*"%>
<%
	int id = Integer.parseInt(request.getParameter("id"));
    String lb = null;
    if((request.getParameter("category")!=null)){
    lb = request.getParameter("category");
    }else if(session.getAttribute("category")!=null){
    lb =session.getAttribute("category").toString();
    }else{
    response.sendRedirect("../backstage.jsp");
    }
    session.setAttribute("category", lb);
	SfgkBean sfgkBean = new SfgkBean();
    sfgkBean = sfgkBean.findNewsById(id);
%>
<!DOCTYPE html>
<html>

<head>

<style type="text/css">
table {
	margin-top: 5px;
	width: 100%;
}

td {
	height: 35px;
}

.left {
	width: 12%;
	text-align: center;
	background-color: #e6f2fe;
}

.form {
	border-color: #acd0d0;
}

.pic {
	height: 200px;
	text-align: center;
}
</style>


<meta charset="UTF-8">
<title>Insert title here</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../webupload/bootstrap/css/bootstrap.min.css"
	rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css"
	href="../webupload/webuploader.css">
<link rel="stylesheet" type="text/css" href="../webupload/style.css">
<style type="text/css">
.update_input {
	margin-top: 5px;
	margin-bottom: 5px;
	width: 100%;
}
</style>
</head>
<!--  -->
<body
	style="padding-left: 20px; padding-right: 20px; padding-bottom: 50px;">

	<div class="abroad">
		<div class="within">
			<div>
				<table class="form" border="1" cellpadding="5" cellspacing="0">
					<tbody>
						<tr>
							<td class="left">*分类：</td>
							<td class="right" style="padding-left: 3px;"><select
								id="category" name="channelId"
								value="<%=sfgkBean.getCategory()%>"
								style="height: 30px; width: 40%;">
								<option value="ggl" class="sel-disabled">公告栏</option>
								
							</select></td>
							<td class="left">是否放在首页：</td>
							<td colspan="3"><select name="select2" id="homepage"
								style="margin-left: 3px; height: 30px; width: 100px">
									<%
       if(sfgkBean.getHomepage()==1){
      %>
       <option value="1" selected="selected" >是</option>
      <%  
       }else{
      %>
       <option value="1" >是</option>
      <%  
       }
      %>
      <%
       if(sfgkBean.getHomepage()==0){
      %>
       <option value="0" selected="selected" >否</option>
      <%  
       }else{
      %>
       <option value="0" >否</option>
      <%  
       }
      %>
							</select></td>
						</tr>
			<tr>
       <td class="left">*标题：</td>
       <td class="right" style="padding-left: 3px;"><input type="text" id="title"
        value="<%=sfgkBean.getTitle()%>"
        style="width: 99.5%; height: 30px; margin-left: 3px;">
       <td class="left">是否显示：</td>
							<td colspan="3"><select name="select2" id="puton"
								style="margin-left: 3px; height: 30px">
								<%
       if(sfgkBean.getPuton()==1){
      %>
       <option value="1" selected="selected" >是</option>
      <%  
       }else{
      %>
       <option value="1" >是</option>
      <%  
       }
      %>
      <%
       if(sfgkBean.getPuton()==0){
      %>
       <option value="0" selected="selected" >否</option>
      <%  
       }else{
      %>
       <option value="0" >否</option>
      <%  
       }
      %>
								
								
			
							</select></td>
      </tr>
						
						
						
						
						<tr>
							<td class="left">作者：</td>
							<td><input type="text" id="author"
								value="<%=sfgkBean.getAuthor()%>"
								style="width: 40%; height: 30px; margin-left: 3px;"></td>
							<td class="left">发布时间：</td>
							<td><input type="date" id="txtDate"
								value="<%=sfgkBean.getTime()%>"
								style="font-size: 14px; font-family: 华文黑体; margin-left: 3px;"></td>
						</tr>
						<tr>
							<td class="left">来源：</td>
							<td style="width: 40%;"><input id="source"
								value="<%=sfgkBean.getSource()%>"
								style="width: 40%; height: 30px; margin-left: 3px;"></td>
							<td class="left">链接：</td>
							<td><input type="" name=""
								style="width: 40%; height: 30px; margin-left: 3px;"></td>
						</tr>
						<tr>
							<td class="left pic">原来图片：</td>
							<td class="pic">
								</td>
							<td class="left">修改图片：</td>
							<td class="pic">
								<div class="uploader uploader1" style="margin: 5px;">
									<div class="wrapper">
										<div class="file-list"></div>
									</div>
									<div class="actions-area">
										<div class="actions">
											<div class="filePicker action">选择图片</div>
											<button class="uploadFile action upload-btn disabled">上传图片</button>
										</div>
									</div>
								</div>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<div>
		<div style="margin-bottom: 20px">
			<input id="picture" value="<%%>"
				style="display: none;" />
			<div>
				<script>
   document.getElementById("category").value = "<%=sfgkBean.getCategory()%>";
</script>

				<script id="container" type="text/plain" style="width: 100%">
            <%=sfgkBean.getContent()%>
</script>
				<div style="text-align: center;">
					<button id="submit" class="update_button">递交</button>
				</div>
				<script type="text/javascript"
					src="../ueditor/third-party/jquery-1.10.2.js"></script>
				<!-- 配置文件 -->
				<script type="text/javascript" src="../ueditor/ueditor.config.js"></script>
				<!-- 编辑器源码文件 -->
				<script type="text/javascript" src="../ueditor/ueditor.all.js"></script>
				<!-- 实例化编辑器 -->
				<script type="text/javascript">
				var editor = UE.getEditor('container');
				$("#submit").click(function () {
					var data = editor.getContent();
					var category = $("#category").val();
					var categoryname = $("#category").find("option:selected").text();
					var title = $("#title").val();
					var homepage = $("#homepage").val();
					var source = $("#source").val();
					var author = $("#author").val();
					var txtDate = $("#txtDate").val();
					var puton = $("#puton").val();
					var id= $("#id").val();
					$.ajax({
						cache: true,
						type: "post",
						url: "donews/updata.jsp",
						data: {
							data: data,
							category: category,
							categoryname:categoryname,
							title: title,
							 homepage:homepage,
							source: source,
							author: author,
							txtDate: txtDate,
							puton:puton,
						    id:<%=id%>
					},
						async : false,
						error : function (request) {
							alert("Connection error");
						},
						success: function (data) {
						     if(data=='true'){
						      alert("成功");     
						      window.location.href = "sfgkcontent.jsp?category=<%=session.getAttribute("category")%>";
						     }else{
						      alert("操作异常");
						     }
						     
						    }
												});
									});
				</script>
				<script src="../webupload/jquery.min.js"></script>
				<!-- Include all compiled plugins (below), or include individual files as needed -->
				<script src="../webupload/bootstrap/js/bootstrap.min.js"></script>
				<script src="../webupload/webuploader.js"></script>
				<script src="../webupload/webuploader.support.js"></script>
				<script>
					var w1 = new WebUploaderSupport({
						server : "../FileUploadServlet",
						paste : document.body,
						swf : '../webuploader/Uploader.swf' // swf文件所处路径
						,
						support : {
							uploader : ".uploader.uploader1", //上传区域容器选择器
							fileSize : 6, //文件总个数, -1时无限制

							uploadSuccess : function(file, data) {
								var $item = this.getItem(file), $state = $item
										.find('.state');
								$item.find('.progress').hide();
								if (data.status) { //上传成功时
									this.uploadSuccessCallbck($item, data); //用于标识为服务端文件
									if (!$state.hasClass('success')) {
										$state.attr("class", "state success");
										$state.text('上传成功');
										$("#myimg").attr("src", data.path);
										$("#picture").attr("value", data.path);
										$item.attr("data-server-file", "true");
										$item.attr("data-delete-url",
												data.delurl);
										alert(data.delurl);
									}
									$item.removeClass("retry");
								} else {
									if (!$state.hasClass('error')) {
										$state.attr("class", "state error");
										$state.text('上传失败');
									}
									$item.addClass("retry");
								}
							},

							deleteServerFile : function($item, url,
									deleteServerFileCallback) {
								var self = this;
								$.ajax({
									dataType : "json",
									type : "post",
									url : "../" + url,
									success : function(json) {
										deleteServerFileCallback(self, $item,
												json); //通过callback执行业务操作
										//文件操作完成后重新加载选择按钮样式
										self.loadChooseFileBtnStyle();
										$("#myimg").attr("src", "");
										$("#picture").attr("value", "");
									}
								});
							},
						}
					});
				</script>
			</div>
</body>

</html>